home *** CD-ROM | disk | FTP | other *** search
/ PC Direct 1998 August / PC Direct August 1998.iso / S / powerj / Product / hpp.z / WCANVAS.HPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-11-25  |  27.9 KB  |  892 lines

  1.  
  2. /*************************************************************************
  3.  *
  4.  * WCanvas
  5.  *
  6.  *************************************************************************/
  7.  
  8. #ifndef _WCANVAS_HPP_INCLUDED
  9. #define _WCANVAS_HPP_INCLUDED
  10. #pragma once
  11.  
  12. #ifndef _WNO_PRAGMA_PUSH
  13. #pragma pack(push,8);
  14. #pragma enum int;
  15. #endif
  16.  
  17. #ifndef _WPOINT_HPP_INCLUDED
  18. #  include "wpoint.hpp"
  19. #endif
  20. #ifndef _WRECT_HPP_INCLUDED
  21. #  include "wrect.hpp"
  22. #endif
  23. #ifndef _WREGION_HPP_INCLUDED
  24. #  include "wregion.hpp"
  25. #endif
  26.  
  27. class WFont;
  28. class WBrush;
  29. class WPalette;
  30. class WColor;
  31. class WPen;
  32. class WBitmap;
  33. class WIcon;
  34. class WCursor;
  35. class WWindow;
  36. class WPrinterData;
  37.  
  38. #ifndef _WIN16
  39. #undef TextOut
  40. #undef DrawText
  41. #undef GetTextMetrics
  42. #if defined( _UNICODE )
  43. #define TextOut         TextOutW
  44. #define DrawText        DrawTextW
  45. #define GetTextMetrics  GetTextMetricsW
  46. #else
  47. #define TextOut         TextOutA
  48. #define DrawText        DrawTextA
  49. #define GetTextMetrics  GetTextMetricsA
  50. #endif
  51. #endif
  52.  
  53. #define WROPBlackness                   ((WULong)0x00000042L)
  54. #define WROPWhiteness                   ((WULong)0x00FF0062L)
  55. #define WROPCopySource                  ((WULong)0x00CC0020L)
  56. #define WROPPaintSource                 ((WULong)0x00EE0086L)
  57. #define WROPEraseSource                 ((WULong)0x00440328L)
  58. #define WROPInvertSource                ((WULong)0x00660046L)
  59. #define WROPCombineSource               ((WULong)0x008800C6L)
  60. #define WROPCopySourceAndInvert         ((WULong)0x00330008L)
  61. #define WROPEraseSourceAndInvert        ((WULong)0x001100A6L)
  62.  
  63. #define WTextAlignBaseline              ((WULong)0x00000018L)
  64. #define WTextAlignBottom                ((WULong)0x00000008L)
  65. #define WTextAlignTop                   ((WULong)0x00000000L)
  66. #define WTextAlignCenter                ((WULong)0x00000006L)
  67. #define WTextAlignLeft                  ((WULong)0x00000000L)
  68. #define WTextAlignRight                 ((WULong)0x00000002L)
  69. #define WTextAlignRTLReading            ((WULong)0x00000100L)
  70. #define WTextAlignRightToLeftReading    ((WULong)0x00000100L)
  71. #define WTextAlignNoUpdateCP            ((WULong)0x00000000L)
  72. #define WTextAlignNoUpdateCurrentPos    ((WULong)0x00000000L)
  73. #define WTextAlignUpdateCP              ((WULong)0x00000001L)
  74. #define WTextAlignUpdateCurrentPos      ((WULong)0x00000001L)
  75.  
  76. #define WDrawOptionOpaque                   0x0002
  77. #define WDrawOptionClipped                  0x0004
  78. #define WDrawOptionGlyphIndex               0x0010
  79. #define WDrawOptionRightToLeftReading       0x0080
  80.  
  81. enum WCBackgroundMode {
  82.     WCBMTransparent = 1,
  83.     WCBMOpaque = 2,
  84. };
  85.  
  86. enum WCMappingMode {
  87.     WCMMError = 0,
  88.     WCMMText = 1,           WCMMPixels = WCMMText,
  89.     WCMMLoMetric = 2,
  90.     WCMMHiMetric = 3,
  91.     WCMMLoEnglish = 4,
  92.     WCMMHiEnglish = 5,
  93.     WCMMTwips = 6,
  94.     WCMMIsotropic = 7,
  95.     WCMMAnisotropic = 8
  96. };
  97.  
  98. enum WCanvasCapabilities {
  99.     WCCHorizontalMM = 4,          // millimeters
  100.     WCCVerticalMM = 6,          // millimeters
  101.     WCCHorizontalPixels = 8,
  102.     WCCVerticalPixels = 10,
  103.     WCCLogicalPixelsX = 88,
  104.     WCCLogicalPixelsY = 90,
  105. };
  106.  
  107. enum WFloodFillTypes {
  108.     WFFBorder = 0,
  109.     WFFSurface = 1
  110. };
  111.  
  112. enum WForeMixMode {
  113.     WFMMBlack           = 1,
  114.     WFMMNotMergePen     = 2,
  115.     WFMMMAskNotPen      = 3,
  116.     WFMMNotCopyPen      = 4,
  117.     WFMMMaskPenNot      = 5,
  118.     WFMMNot             = 6,
  119.     WFMMXorPen          = 7,
  120.     WFMMNotMaskPen      = 8,
  121.     WFMMMaskPen         = 9,
  122.     WFMMNororPen        = 10,
  123.     WFMMNop             = 11,
  124.     WFMMMergeNorPen     = 12,
  125.     WFMMCopyPen         = 13,
  126.     WFMMMergePenNot     = 14,
  127.     WFMMMergePen        = 15,
  128.     WFMMWhite           = 16,
  129.     WFMMLast            = 16,
  130. };
  131.  
  132. enum WArcDirection {
  133.     WADCounterClockWise = 1,
  134.     WADClockWise        = 2,
  135. };
  136.  
  137. #define WDrawTextTop              ((WULong)0x00000000)
  138. #define WDrawTextLeft             ((WULong)0x00000000)
  139. #define WDrawTextCenter           ((WULong)0x00000001)
  140. #define WDrawTextRight            ((WULong)0x00000002)
  141. #define WDrawTextVCenter          ((WULong)0x00000004)
  142. #define WDrawTextBottom           ((WULong)0x00000008)
  143. #define WDrawTextWordBreak        ((WULong)0x00000010)
  144. #define WDrawTextSingleLine       ((WULong)0x00000020)
  145. #define WDrawTextExpandTabs       ((WULong)0x00000040)
  146. #define WDrawTextTabStop          ((WULong)0x00000080)
  147. #define WDrawTextNoClip           ((WULong)0x00000100)
  148. #define WDrawTextExternalLeading  ((WULong)0x00000200)
  149. #define WDrawTextCalcRect         ((WULong)0x00000400)
  150. #define WDrawTextNoPrefix         ((WULong)0x00000800)
  151. #define WDrawTextEditControl      ((WULong)0x00002000)
  152. #define WDrawTextPathEllipsis     ((WULong)0x00004000)
  153. #define WDrawTextEndEllipsis      ((WULong)0x00008000)
  154. #define WDrawTextModifyString     ((WULong)0x00010000)
  155. #define WDrawTextRTLReading       ((WULong)0x00020000)
  156. #define WDrawTextWordEllipsis     ((WULong)0x00040000)
  157.  
  158. #define WDrawTextDefault          ((WULong)0x00000800)
  159.  
  160. #define WDrawIconCompat         0x0004
  161. #define WDrawIconDefaultSize    0x0008
  162. #define WDrawIconImage          0x0002
  163. #define WDrawIconMask           0x0001
  164. #define WDrawIconNormal         0x0003
  165.  
  166. #define WDrawCursorCompat       WDrawIconCompat         
  167. #define WDrawCursorDefaultSize  WDrawIconDefaultSize    
  168. #define WDrawCursorImage        WDrawIconImage          
  169. #define WDrawCursorMask         WDrawIconMask           
  170. #define WDrawCursorNormal       WDrawIconNormal
  171.  
  172. class WCanvasReference; // internal use only
  173.  
  174. //
  175. // TextMetrics -- Use to obtain information on a selected font.
  176. //
  177.  
  178. struct WTextMetrics {
  179.     WLong height;
  180.     WLong ascent;
  181.     WLong descent;
  182.     WLong internalLeading;
  183.     WLong externalLeading;
  184.     WLong averageWidth;
  185.     WLong maximumWidth;
  186. };
  187.  
  188. //
  189. // WInfoCanvas
  190. //
  191.  
  192. #pragma warning 849 9
  193.  
  194. class WCMCLASS WInfoCanvas : public WObject {
  195.     WDeclareSubclass( WInfoCanvas, WObject );
  196.  
  197.     public:
  198.  
  199.         /**********************************************************
  200.          * Constructors and Destructors
  201.          *********************************************************/
  202.  
  203.         WInfoCanvas();
  204.         WInfoCanvas( const WInfoCanvas & canvas );
  205.         WInfoCanvas( WDeviceHandle dev, WBool deleteHandle=FALSE );
  206.         WInfoCanvas( const WChar *driverName, const WChar *deviceName,
  207.                      const void *deviceData );
  208.         ~WInfoCanvas();
  209.  
  210.         WInfoCanvas& operator=( const WInfoCanvas & ic );
  211.  
  212.         /**********************************************************
  213.          * Properties
  214.          *********************************************************/
  215.  
  216.         // Handle
  217.         //
  218.         //    Returns the low-level HDC that corresponds to the canvas.
  219.  
  220.         WDeviceHandle GetHandle() const;
  221.  
  222.         // Size
  223.         //
  224.         //    Returns a rectangle representing the size (in pixels)
  225.         //    of the canvas, with top & left always set to 0.
  226.  
  227.         WRect GetSize() const;
  228.  
  229.         /**********************************************************
  230.          * Methods
  231.          *********************************************************/
  232.  
  233.         // Clear
  234.  
  235.         virtual void Clear();
  236.  
  237.         // Create
  238.  
  239.         virtual WBool Create( const WInfoCanvas & canvas );
  240.         virtual WBool Create( WDeviceHandle dev, WBool deleteHandle=FALSE );
  241.         virtual WBool Create( const WChar * driverName,
  242.                               const WChar * deviceName,
  243.                               const void * deviceData );
  244.  
  245.         // QueryCapability
  246.         //
  247.         //    Query the capabilities the device has.
  248.  
  249.         WInt QueryCapability( WCanvasCapabilities capability ) const;
  250.  
  251.         /**********************************************************
  252.          * Static Methods
  253.          *********************************************************/
  254.  
  255.         // IsValidHandle
  256.         //
  257.         //    Returns TRUE if the given handle is valid.
  258.  
  259.         static WBool IsValidHandle( WDeviceHandle handle,
  260.                                     WBool nullValid=FALSE );
  261.  
  262.         /**********************************************************
  263.          * Private
  264.          *********************************************************/
  265.  
  266.     protected:
  267.  
  268.         WCanvasReference *_ref;
  269. };
  270.  
  271. //
  272. // WCanvas
  273. //
  274.  
  275. class WCMCLASS WCanvas : public WInfoCanvas {
  276.     WDeclareSubclass( WCanvas, WInfoCanvas );
  277.     
  278.     public:
  279.  
  280.         /**********************************************************
  281.          * Constructors and Destructors
  282.          *********************************************************/
  283.  
  284.         WCanvas();
  285.         WCanvas( WDeviceHandle dev, WBool deleteHandle=FALSE );
  286.         WCanvas( const WChar *driverName, const WChar *deviceName,
  287.                  const void *deviceData );
  288.         WCanvas( const WCanvas & canvas, WBool makeMemoryDC=FALSE ); 
  289.  
  290.         ~WCanvas();
  291.  
  292.         WCanvas& operator=( const WCanvas & c );
  293.  
  294.         /**********************************************************
  295.          * Properties
  296.          *********************************************************/
  297.  
  298.         // ArcDirection
  299.         //
  300.         //     The drawing direction to be used for arc and rectangle
  301.         //     functions
  302.  
  303.         WBool SetArcDirection( WArcDirection direction );
  304.         WArcDirection GetArcDirection();
  305.  
  306.         // AutomaticReset
  307.         //
  308.         //    If set to TRUE, the canvas will automatically do a
  309.         //    Reset upon destruction or invocation of the Clear method
  310.         //    Note: The Set will only succeed if the canvas has a valid
  311.         //          device handle
  312.  
  313.         WBool GetAutomaticReset() const;
  314.         WBool SetAutomaticReset( WBool automaticReset );
  315.  
  316.         // BackColor
  317.         //
  318.         //    Set the background color for drawing.
  319.  
  320.         WBool  SetBackColor( const WColor & color );
  321.         WColor GetBackColor() const;
  322.  
  323.         // BackMode
  324.         //
  325.         //    Set/get the background drawing mode.
  326.  
  327.         WBool            SetBackMode( WCBackgroundMode mode );
  328.         WCBackgroundMode GetBackMode() const;
  329.  
  330.         // Bitmap
  331.         //
  332.         //    Set/get the bitmap associated with a canvas.
  333.  
  334.         WBool SetBitmap( const WBitmap & newBitmap );
  335.         WBitmap GetBitmap() const;
  336.  
  337.         // Brush
  338.         //
  339.         //    Set/get the brush associated with a canvas.
  340.  
  341.         WBool SetBrush( const WBrush & newBrush );
  342.         WBrush GetBrush() const;
  343.  
  344.         // ClippingRectangle
  345.         //
  346.         //    Returns the current clipping rectangle.
  347.  
  348.         WRect GetClippingRectangle() const;
  349.         WBool SetClippingRectangle( const WRect & r );
  350.  
  351.         // DrawPosition
  352.         //
  353.         //    The current position of the pen.
  354.  
  355.         WBool  SetDrawPosition( const WPoint & point );
  356.         WPoint GetDrawPosition() const;
  357.  
  358.         // Font
  359.         //
  360.         //    Set/get the font associated with a canvas.
  361.  
  362.         WBool SetFont( const WFont & newFont );
  363.         WFont GetFont() const;
  364.  
  365.         // ForeMixMode
  366.         //
  367.         //     The current foreground mix mode
  368.  
  369.         WBool SetForeMixMode( WForeMixMode mode );
  370.         WForeMixMode GetForeMixMode();
  371.  
  372.         // MappingMode
  373.         //
  374.         //    Set/get the mapping mode for the canvas.
  375.  
  376.         WCMappingMode GetMappingMode() const;
  377.         WBool         SetMappingMode( WCMappingMode mode );
  378.  
  379.         // Palette
  380.         //
  381.         //    Set/get the palette associated with a canvas.
  382.         //    Choose forceBackground=TRUE when RealizePalette is to
  383.         //    map the logical palette to the physical palette (in the
  384.         //    best possible way).
  385.  
  386.         WBool SetPalette( const WPalette & newPalette,
  387.                           WBool forceBackground=FALSE );
  388.         WPalette GetPalette() const;
  389.  
  390.         // Pen
  391.         //
  392.         //    Set/get the pen associated with a canvas.
  393.  
  394.         WBool SetPen( const WPen & newPen );
  395.         WPen GetPen() const;
  396.  
  397.         // PolygonFillMode
  398.         //
  399.         //    Set/get the polygon fill mode
  400.  
  401.         WBool            SetPolygonFillMode( WPolygonFillMode mode );
  402.         WPolygonFillMode GetPolygonFillMode() const;
  403.  
  404.         // TextAlignment
  405.         //
  406.         //    The text alignment.
  407.  
  408.         WBool  SetTextAlignment( WULong flags );
  409.         WULong GetTextAlignment() const;
  410.  
  411.         // TextColor
  412.         //
  413.         //    The text color for drawing.
  414.  
  415.         WBool  SetTextColor( const WColor & color );
  416.         WColor GetTextColor() const;
  417.  
  418.         // TextMetrics
  419.         //
  420.         //    Returns metrics of the currently-selected font.
  421.  
  422.         WTextMetrics GetTextMetrics() const;
  423.  
  424.         /**********************************************************
  425.          * Methods
  426.          *********************************************************/
  427.  
  428.         // CalculateTextRectangle
  429.  
  430.         WBool CalculateTextRectangle( WRect & r, const WChar *text,
  431.                                       WInt numChars=-1 );
  432.  
  433.         // CalculateWrapLength
  434.         //
  435.         //    Given a width and a string, determines how many
  436.         //    characters in that string will fit in the width.
  437.         //    Also optinally fills in an array of text extents
  438.         //    for each character, up to the # of characters that
  439.         //    will fit.
  440.  
  441.         WInt CalculateWrapLength( WInt width, const WChar *text,
  442.                                   WInt numChars=-1, WInt *extents=NULL );
  443.  
  444.         // Clear
  445.         //
  446.         //    This clears (release or destroys) the HDC that
  447.         //    for the canvas.
  448.  
  449.         virtual void Clear();
  450.  
  451.         // Create
  452.  
  453.         virtual WBool Create( const WInfoCanvas & canvas );
  454.         virtual WBool Create( WDeviceHandle dev, WBool deleteHandle=FALSE );
  455.         virtual WBool Create( const WChar * driverName,
  456.                               const WChar * deviceName,
  457.                               const void * deviceData );
  458.         virtual WBool Create( const WCanvas & canvas,
  459.                               WBool makeMemoryDC=FALSE );
  460.  
  461.         // DrawArc
  462.         //
  463.         //     Draws an elliptical arc
  464.  
  465.         WBool DrawArc( const WRect & boundingRect, const WPoint & radial1end,
  466.                        const WPoint & radial2end,
  467.                        WBool useCurrentPosition=TRUE );
  468.  
  469.         // DrawBezierCurves
  470.         //
  471.         //     Draws a series of Bezier curves
  472.  
  473.         WBool DrawBezierCurves( WPoint * pointArray, WInt numPoints,
  474.                                 WBool useCurrentPosition=TRUE );
  475.  
  476.         // DrawBitmap
  477.         //
  478.         //    Draws a bitmap,
  479.  
  480.         WBool DrawBitmap( const WBitmap & bitmap, const WRect & dest,
  481.                           WBool stretch=TRUE, WULong rop=WROPCopySource );
  482.         WBool DrawBitmap( const WBitmap & bitmap, const WRect & dest,
  483.                           const WRect & src, WBool stretch=TRUE,
  484.                           WULong rop=WROPCopySource );
  485.  
  486.         // DrawChord
  487.         //
  488.         //     Draws a chord (a region bounded by the intersection of an
  489.         //                    ellipse and a line segment)
  490.  
  491.         WBool DrawChord( const WRect & boundingRect,
  492.                          const WPoint & radial1end,
  493.                          const WPoint & radial2end );
  494.  
  495.         // DrawEllipse
  496.         //
  497.         //    Draws an ellipse centered on the given rectangle.
  498.  
  499.         WBool DrawEllipse( const WRect & r, WBool fill=TRUE );
  500.  
  501.         // DrawFromCanvas
  502.         //
  503.         //    Draws the contents of another canvas into this canvas.
  504.  
  505.         WBool DrawFromCanvas( const WRect & destination,
  506.                               const WCanvas & sourceCanvas,
  507.                               WULong rop=WROPCopySource );
  508.         WBool DrawFromCanvas( const WRect & destination,
  509.                               const WPoint & source,
  510.                               const WCanvas & sourceCanvas,
  511.                               WULong rop=WROPCopySource );
  512.         WBool DrawFromCanvas( const WRect & destination,
  513.                               const WRect & source,
  514.                               const WCanvas & sourceCanvas,
  515.                               WULong rop=WROPCopySource,
  516.                               WBool stretch=FALSE );
  517.  
  518.         // DrawFocusRectangle
  519.         //
  520.         //    Draws a focus rectangle.  Call it a second time to
  521.         //    erase it.  
  522.  
  523.         WBool DrawFocusRectangle( const WRect & r );
  524.  
  525.         // DrawIcon
  526.         //
  527.         //    Draws an icon.
  528.  
  529.         WBool DrawIcon( const WIcon & icon, const WPoint & loc );
  530.         WBool DrawIcon( const WIcon & icon, const WPoint & loc,
  531.                         const WSize & size, WULong flags=WDrawIconNormal,
  532.                         const WBrush *brush=NULL, WULong index=0 );
  533.  
  534.         // DrawCursor
  535.         //
  536.         //    Draws an cursor.
  537.  
  538.         WBool DrawCursor( const WCursor & cursor, const WPoint & loc );
  539.         WBool DrawCursor( const WCursor & cursor, const WPoint & loc,
  540.                         const WSize & size, WULong flags=WDrawCursorNormal,
  541.                         const WBrush *brush=NULL, WULong index=0 );
  542.  
  543.         // DrawLine
  544.         //
  545.         //    Draws a line from the current/given position to the given
  546.         //    point.  Moves the current point.
  547.  
  548.         WBool DrawLine( const WPoint & endPoint );
  549.         WBool DrawLine( const WPoint & startPoint, const WPoint & endPoint );
  550.  
  551.         // DrawLines
  552.         //
  553.         //     Draws a series of line segments
  554.  
  555.         WBool DrawLines( WPoint * pointArray, WInt numPoints,
  556.                          WBool useCurrentPosition=TRUE );
  557.  
  558.         // DrawPolygons
  559.         //
  560.         //     Draw a series of closed polygons
  561.         
  562.         WBool DrawPolygons( WPoint * pointArray, WInt * vertexCountArray,
  563.                             WInt numPolygons );
  564.  
  565.         // DrawPie
  566.         //
  567.         //    Draws a pie piece.
  568.  
  569.         WBool DrawPie( const WRect & rect, const WPoint & firstRadial,
  570.                        const WPoint & secondRadial );
  571.     
  572.         // DrawPolygon
  573.         //
  574.         //    Draws a polygon.
  575.  
  576.         WBool DrawPolygon( WPoint * pointArray, WInt numPoints );
  577.  
  578.         // DrawRectangle
  579.         //
  580.         //    Draws a rectangle.  The outline is drawn with the current
  581.         //    pen, the inside is filled with the current brush if
  582.         //    fill is true.
  583.  
  584.         WBool DrawRectangle( const WRect & rect, WBool fill=TRUE );
  585.  
  586.         // DrawRoundRectangle
  587.         //
  588.         //    Like DrawRectangle, but draws round corners.
  589.  
  590.         WBool DrawRoundRectangle( const WRect & rect, WInt cornerWidth,
  591.                                   WInt cornerHeight, WBool fill=TRUE );
  592.  
  593.         // DrawText
  594.         //
  595.         //    Draws text.  The first form calls TextOut to draw a line
  596.         //    of text.  The second calls DrawTextEx to draw a line
  597.         //    or lines.  The third calls API DrawText. The forth call
  598.         //    ExtTextOut. In all cases if you pass an outputRect
  599.         //    as the last parameter, no drawing is done, but instead
  600.         //    the size of the drawn text is calculated.
  601.  
  602.         WBool DrawText( const WChar *string, WInt numChars=-1,
  603.                         WRect *outputRect=NULL, WInt space = 0);
  604.         WBool DrawText( const WPoint & pt, const WChar *string,
  605.                         WInt numChars=-1, 
  606.                         WRect *outputRect=NULL, WInt space = 0);
  607.         WBool DrawText( const WRect & rect, const WChar *string,
  608.                         WInt numChars=-1, WULong flags=WDrawTextDefault,
  609.                         WRect *outputRect=NULL );
  610.         WBool DrawText( const WPoint & pt, const WChar *string,
  611.                         WInt numChars, WUInt drawOptions,
  612.                         WRect clippingRect, WIntArray * spacing,
  613.                         WRect *outputRect=NULL);
  614.  
  615.         // FillRectangle
  616.         //
  617.         //    Fill the given rectangle.  If no brush is given, uses
  618.         //    the current brush setting.
  619.  
  620.         WBool FillRectangle( const WRect & rect,
  621.                              const WBrush * useBrush=NULL );
  622.  
  623.         // FillRegion
  624.         //
  625.         //    Fill the given region.  If no brush is given, uses
  626.         //    the current brush setting.
  627.  
  628.         WBool FillRegion( const WRegion & region,
  629.                           const WBrush * useBrush=NULL );
  630.  
  631.         // FloodFill
  632.  
  633.         WBool FloodFill( const WPoint & start, const WColor & borderColor,
  634.                          WFloodFillTypes type=WFFBorder );
  635.  
  636.         // FrameRectangle
  637.         //
  638.         //    Draws border around specified rectangle using brush, 1 unit wide
  639.  
  640.         WBool FrameRectangle( const WRect & rect, const WBrush * brush=NULL );
  641.  
  642.         // FrameRegion
  643.         //
  644.         //    Frame the given region.  If no brush is given, uses
  645.         //    the current brush setting.
  646.  
  647.         WBool FrameRegion( const WRegion & region,
  648.                            const WBrush * useBrush=NULL,
  649.                            WInt width=1, WInt height=1 );
  650.  
  651.         // InvertRectangle
  652.         //
  653.         //    Inverts a rectangle by performing a logical NOT operation
  654.  
  655.         WBool InvertRectangle( const WRect & rect );
  656.  
  657.         // InvertRegion
  658.  
  659.         WBool InvertRegion( const WRegion & region );
  660.  
  661.         // PaintRegion
  662.         //
  663.         //    Uses the current brush setting
  664.  
  665.         WBool PaintRegion( const WRegion & region );
  666.  
  667.         // RealizePalette
  668.  
  669.         WInt RealizePalette();
  670.  
  671.         // Reset
  672.         //
  673.         //    Resets the canvas to its original state, optionally
  674.         //    popping the stack of saved states.
  675.  
  676.         WBool Reset( WBool popStack=TRUE );
  677.  
  678.         // Restore
  679.         //
  680.         //    Restores the canvas to a previously-saved state.
  681.  
  682.         WBool Restore( WInt stateIndex );
  683.  
  684.         // Save
  685.         //
  686.         //    Saves the canvas state.  If return value is 0,
  687.         //    failed, otherwise it's the state index.
  688.  
  689.         WInt Save();
  690.  
  691.         // UpdateColors
  692.  
  693.         WBool UpdateColors();
  694.  
  695.         /**********************************************************
  696.          * Item Properties
  697.          *********************************************************/
  698.  
  699.         // SetPixel/GetPixel
  700.         //
  701.         // Get or set the colour of a given pixel location
  702.         //
  703.         // Note: GetPixel() will not always work for an arbitrary location,
  704.         // even if the point is within the bounds of your DC. It will only
  705.         // work if the point being retrieved is inside the clipping
  706.         // region. Also note that you can only make the clipping region
  707.         // SMALLER than the current clipping region. 
  708.         // See MS Knowledge base PSS ID #: Q119472 for more info.
  709.  
  710.         WBool SetPixel( WPoint loc, WColor &color,
  711.                         WBool useClosestColor = FALSE );
  712.         WColor GetPixel( WPoint loc );
  713.  
  714.         /**********************************************************
  715.          * Private
  716.          *********************************************************/
  717.  
  718.     protected:
  719. };
  720.  
  721. //
  722. // WDisplayCanvas
  723. //
  724.  
  725. class WCMCLASS WDisplayCanvas : public WCanvas {
  726.     WDeclareSubclass( WDisplayCanvas, WCanvas );
  727.  
  728.     public:
  729.  
  730.         /**********************************************************
  731.          * Constructors and Destructors
  732.          *********************************************************/
  733.  
  734.         WDisplayCanvas();
  735.         WDisplayCanvas( const WDisplayCanvas & canvas );
  736.         WDisplayCanvas( WDeviceHandle dev, WBool deleteHandle=FALSE,
  737.                         const WWindow *window=NULL );
  738.         WDisplayCanvas( const WChar *driverName, const WChar *deviceName,
  739.                         const void *deviceData );
  740.         WDisplayCanvas( const WWindow *window, WBool inPaint=FALSE,
  741.                         WBool nonClient=FALSE );
  742.  
  743.         ~WDisplayCanvas();
  744.  
  745.         WDisplayCanvas& operator=( const WDisplayCanvas & c );
  746.  
  747.         /**********************************************************
  748.          * Methods
  749.          *********************************************************/
  750.  
  751.         // Clear
  752.  
  753.         virtual void Clear();
  754.  
  755.         // Create
  756.  
  757.         virtual WBool Create( const WDisplayCanvas & canvas );
  758.         virtual WBool Create( WDeviceHandle dev, WBool deleteHandle=FALSE,
  759.                               const WWindow * window=NULL );
  760.         virtual WBool Create( const WChar * driverName,
  761.                               const WChar * deviceName,
  762.                               const void * deviceData );
  763.         virtual WBool Create( const WWindow * window, WBool inPaint=FALSE,
  764.                               WBool nonClient=FALSE );
  765.  
  766.         /**********************************************************
  767.          * Private
  768.          *********************************************************/
  769.  
  770.     protected:
  771.  
  772.         const WWindow *_window;
  773. };
  774.     
  775. //
  776. // WPrinterCanvas
  777. //
  778.  
  779. class WCMCLASS WPrinterCanvas : public WCanvas {
  780.     WDeclareSubclass( WPrinterCanvas, WCanvas );
  781.  
  782.  
  783.     public:
  784.  
  785.         /**********************************************************
  786.          * Constructors and Destructors
  787.          *********************************************************/
  788.  
  789.         WPrinterCanvas();
  790.         WPrinterCanvas( const WPrinterCanvas & canvas );
  791.         WPrinterCanvas( WDeviceHandle dev, WBool deleteHandle=FALSE );
  792.         WPrinterCanvas( const WChar *driverName, const WChar *deviceName,
  793.                         const void *deviceData );
  794.         WPrinterCanvas( const WPrinterData & printerData );
  795.  
  796.         ~WPrinterCanvas();
  797.  
  798.         WPrinterCanvas& operator=( const WPrinterCanvas & c );
  799.  
  800.         /**********************************************************
  801.          * Properties
  802.          *********************************************************/
  803.  
  804.         // JobID
  805.         //
  806.         //    Returns the current job ID if a document is being
  807.         //    printed.
  808.  
  809.         WInt GetJobID() const;
  810.  
  811.         // PageNumber
  812.         //
  813.         //    Returns the current page number if a document is
  814.         //    being printed.
  815.  
  816.         WInt GetPageNumber() const;
  817.  
  818.         /**********************************************************
  819.          * Methods
  820.          *********************************************************/
  821.  
  822.         // AbortDocument
  823.  
  824.         WBool AbortDocument();
  825.  
  826.         // Clear
  827.  
  828.         virtual void Clear();
  829.  
  830.         // Create
  831.  
  832.         virtual WBool Create( const WPrinterCanvas & canvas );
  833.         virtual WBool Create( WDeviceHandle dev, WBool deleteHandle=FALSE );
  834.         virtual WBool Create( const WChar * driverName,
  835.                               const WChar * deviceName,
  836.                               const void * deviceData );
  837.         virtual WBool Create( const WPrinterData & printerData );
  838.  
  839.         // EndDocument
  840.         //
  841.         //    Finish spooling the document.
  842.  
  843.         WBool EndDocument();
  844.  
  845.         // EndPage
  846.         //
  847.         //    Finish spooling a page.
  848.  
  849.         WBool EndPage();
  850.  
  851.         // StartDocument
  852.         //
  853.         //    Prepare a new document for printing.  If this is called
  854.         //    while still printing a document, the current document
  855.         //    is ended first.
  856.  
  857.         WBool StartDocument( const WChar *documentName=NULL,
  858.                              const WChar *printToFilePath=NULL );
  859.  
  860.         // StartPage
  861.         //
  862.         //    Prepare a page for printing.  If this is called while
  863.         //    still printing a page, the current page is ended first.
  864.         //    By default the canvas state is saved across pages.
  865.  
  866.         WBool StartPage( WBool saveState=TRUE );
  867.  
  868.         /**********************************************************
  869.          * Private
  870.          *********************************************************/
  871.  
  872.     private:
  873.         WBool _printingPage;
  874.         WInt  _jobID;
  875.         WInt  _pageNumber;
  876. };
  877.  
  878. #pragma warning 849 1
  879.  
  880. #ifdef _DEBUG
  881. #define W_ISCANVASHANDLE(h) CHECKGDI(WInfoCanvas::IsValidHandle((WDeviceHandle)h))
  882. #else
  883. #define W_ISCANVASHANDLE(h)
  884. #endif
  885.  
  886. #ifndef _WNO_PRAGMA_PUSH
  887. #pragma enum pop;
  888. #pragma pack(pop);
  889. #endif
  890.  
  891. #endif // _WCANVAS_HPP_INCLUDED
  892.